﻿Public Class frmMainForm
#Region " Visual Modifications, Tweaks, and Enhancements "
    Private Shadows Sub OnFormResized(ByVal sender As Toolkit.KryptonForm, ByVal e As EventArgs) Handles Me.Resize
        Me.lstProcesses.Size = New Size(Me.Size.Width, Me.Size.Height - Me.rbnMainRibbon.Size.Height)
        Me.lstProcesses.Location = New Point(0, Me.rbnMainRibbon.Size.Height)
    End Sub

    Private Shadows Sub OnRibbonMinimiseChanged(ByVal sender As Ribbon.KryptonRibbon, ByVal e As EventArgs) Handles rbnMainRibbon.MinimizedModeChanged
        Me.lstProcesses.Size = New Size(Me.Size.Width, Me.Size.Height - Me.rbnMainRibbon.Size.Height)
        Me.lstProcesses.Location = New Point(0, Me.rbnMainRibbon.Size.Height)
    End Sub

    Private Shadows Sub OnListBoxItemSelected(ByVal sender As Toolkit.KryptonListBox, ByVal e As EventArgs) Handles lstProcesses.SelectedValueChanged
        If Me.lstProcesses.SelectedIndices.Count <> 0 Then
            Me.rbnMainRibbon.SelectedContext = "ProcessSelected"
        ElseIf Me.lstProcesses.SelectedIndices.Count = 0 Then
            Me.rbnMainRibbon.SelectedContext = ""
        End If
    End Sub
#End Region

#Region " OnPropertyChanged Handlers "
    Private Shadows Sub OnSettingUpdated(ByVal sender As Ribbon.KryptonRibbonGroupButton, ByVal e As EventArgs) Handles chkHideNotClose.Click, chkHideOnMinimise.Click, chkLargeListing.Click, chkStartup.Click, chkTaskbarIcon.Click
        Select Case sender.TextLine1
            Case "Close to Taskbar"
                My.Settings.HideNotClose = sender.Checked
            Case "Launch at Startup"
                My.Settings.Startup = sender.Checked
            Case "Always Show Taskbar Icon"
                My.Settings.TaskbarIcon = sender.Checked
            Case "Use Large List Entries"
                My.Settings.LargeListEntries = sender.Checked
                If sender.Checked Then
                    Me.lstProcesses.ItemStyle = Toolkit.ButtonStyle.BreadCrumb
                Else
                    Me.lstProcesses.ItemStyle = Toolkit.ButtonStyle.ButtonSpec
                End If
            Case "Hide when Minimised"
                My.Settings.HideOnMinimise = sender.Checked
            Case "Remember Window Data"
                My.Settings.RememberWindowData = sender.Checked
        End Select
        My.Settings.Save()
    End Sub
#End Region

    Private Shadows Sub OnLoad(ByVal sender As Toolkit.KryptonForm, ByVal e As EventArgs) Handles Me.Load
        'Apply settings to form
        Me.chkLargeListing.Checked = My.Settings.LargeListEntries
        Me.chkHideOnMinimise.Checked = My.Settings.HideOnMinimise
        Me.chkHideNotClose.Checked = My.Settings.HideNotClose
        Me.chkStartup.Checked = My.Settings.Startup
        Me.chkTaskbarIcon.Checked = My.Settings.TaskbarIcon
        Me.chkRememberSize.Checked = My.Settings.RememberWindowData

        'Apply extra settings
        If My.Settings.RememberWindowData Then
            Me.Size = My.Settings._WindowSize
            Me.Location = My.Settings._WindowLoc
        End If
    End Sub
End Class
